export default {
  data() {
    return {
      guidePages: false, //隐藏显示登录
      newusser: false, //true新用户，false老用户
    }
  },
  created() {},
  onLoad(e) {
    this.newusser = JSON.parse(e.type)
    this.loadExecution() //调用选择需求
    // 选择品牌，系列，车子
    uni.$on('specifAll', data => {
      Object.assign(this.specifAll, data)
      this.carList.car_Type_Id = 3841
      // console.log(this.specifAll)
      if (this.specifAll.Serieslist.carTypeId !== undefined) {
        this.carList.car_Type_Id = this.specifAll.Serieslist.carTypeId //系列id
      }
    })
  },
  methods: {
    // 点击导航栏右侧
    onNavigationBarButtonTap(e) {
      this.skipClick()
    },
    loadExecution: function() {
      try {
        // const value = uni.getStorageSync('selecerequirments')
        if (this.newusser) {
          // selecerequirments=true直接跳转到首页
          this.guidePages = true
        } else {
          // selecerequirments!=true显示引导页
          uni.switchTab({
            url: '/pages/index/index'
          })
        }
      } catch (e) {
        // error
        uni.setStorage({
          key: 'selecerequirments',
          data: true,
          success: function() {
            console.log('error时存储selecerequirments')
          }
        })
        this.guidePages = true
      }
      return
      uni.switchTab({
        url: '/pages/index/index'
      })
    },
    //获取询比价列表
    async getCarBookList() {
      try {
        let data = {
          'pageIndex': 1,
          'pageSize': 10
        }
        const res = await this.$api.comparison.getCarBookList(data)
        this.list = res.data.list

        console.log(this.list)
        this.id = this.list[0].id
      } catch (e) {
        console.log(e)
      }
    },
    skipClick() {
      /**
       * 向本地存储中设置selecerequirments的值，即启动标识；
       */
      uni.setStorage({
        key: 'selecerequirments',
        data: true,
      })
      uni.switchTab({
        url: '/pages/index/index'
      })
    },
    //我是车主
    mylovercarclick() {
      uni.navigateTo({
        url: '/pages_commodity/myLoveCar/myLoveCar'
      })
    },
    //我要购车
    iwanttobuycar() {
      uni.navigateTo({
        url: '/pages_commodity/myCarList/myCarList'
      })
    }
  }
}
